'''
Author: LHY 2601958675@qq.com
Date: 2023-06-28 15:25:43
LastEditors: LHY
LastEditTime: 2023-07-22 10:40:43
Description:    
'''
from urllib.request import urlopen
import requests
url = "http://www.baidu.com"

#方法一 urlopen
# resp = urlopen(url)
# with open("mybaidu.html",mode='w',encoding='utf-8') as f:
#     f.write(resp.read().decode('utf-8'))pw

# 方法二 requests
resp = requests.get(url)
resp.encoding = 'utf-8'
print(resp.text)

